<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="fields">
	<xsl:variable name="thisname">
		<xsl:choose>
			<xsl:when test="@name"><xsl:value-of select="@name"/></xsl:when>
			<xsl:otherwise>x_form</xsl:otherwise>
		</xsl:choose>
	</xsl:variable>
	<div class="frm_box">
		<table class="frm_table" cellpadding="0" cellspacing="0" border="0">
			<form method="post">
				<xsl:attribute name="name"><xsl:value-of select="$thisname"/></xsl:attribute>
				<xsl:attribute name="action"><xsl:apply-templates select="actions/action[1]"/></xsl:attribute>
				<xsl:if test="fld/@wf_obj='x_file'">
					<xsl:attribute name="enctype"><xsl:text>multipart/form-data</xsl:text></xsl:attribute>
				</xsl:if>
				<xsl:if test="not(@validation='no')"><xsl:call-template name="form-validation"/></xsl:if>
				<xsl:apply-templates select="fld"/>
				<xsl:apply-templates select="actions" mode="button"/>
			</form>
			<xsl:if test="not(fld[@wf_obj='x_text'])">
				<script language="JavaScript">document.<xsl:value-of select="$thisname"/>.onkeypress = x_onFormPress</script>
			</xsl:if>
		</table>
		<xsl:if test="para">
			<div class="frm_para"><xsl:apply-templates select="para"/></div>
		</xsl:if>
	</div>
</xsl:template>

<xsl:template match="fields/actions" mode="button">
	<tr>
		<td colspan="2" class="frm_button"><xsl:apply-templates select="action" mode="button"><xsl:sort select="@order"/></xsl:apply-templates></td>
	</tr>
</xsl:template>

<xsl:template match="action" mode="button">
	<xsl:variable name="thisname"><xsl:call-template name="form-name"/></xsl:variable>
	<xsl:if test="position()&gt;1"><xsl:call-template name="nobrspace"/></xsl:if>
	<input type="Button" class="frm_btn">
		<xsl:attribute name="onclick">
			<xsl:choose>
				<xsl:when test="position()&gt;1 and (@type='form' or @type='service')">
					<xsl:text>javascript:x_frm.Submit(</xsl:text>
					<xsl:value-of select="$thisname"/><xsl:text>,'</xsl:text>
					<xsl:call-template name="action-url"/><xsl:text>', true)</xsl:text>
				</xsl:when>
				<xsl:otherwise>
					<xsl:text>javascript:x_frm.Check(</xsl:text>
					<xsl:value-of select="$thisname"/><xsl:text>, '</xsl:text>
					<xsl:value-of select="@type"/><xsl:text>')</xsl:text>
				</xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
		<xsl:attribute name="name"><xsl:value-of select="@type"/></xsl:attribute>
		<xsl:attribute name="value">
			<xsl:choose>
				<xsl:when test="@label"><xsl:value-of select="@label"/></xsl:when>
				<xsl:otherwise><xsl:text>Submit</xsl:text></xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
	</input>
</xsl:template>

<xsl:template match="fields/action">
	<xsl:call-template name="action-url"/>
</xsl:template>

<xsl:template match="fields/fld">
	<xsl:choose>
		<xsl:when test="@type='special'"><xsl:call-template name="special-flds"><xsl:with-param name="isConfirm">no</xsl:with-param></xsl:call-template></xsl:when>
		<xsl:otherwise><xsl:call-template name="flds"><xsl:with-param name="isConfirm">no</xsl:with-param></xsl:call-template></xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template match="fld/prompt">
	<xsl:apply-templates/>
</xsl:template>

<xsl:template match="label">
	<tr><td colspan="4">
			<div class="frm-fld-lbl">
				<xsl:choose>
					<xsl:when test="text">
						<span class="frm-fld-head"><xsl:value-of select="head"/></span>
						<br/>
						<span class="frm-fld-text"><xsl:value-of select="text"/></span>
					</xsl:when>
					<xsl:otherwise>
						<span class="frm-fld-head"><xsl:value-of select="."/></span>
					</xsl:otherwise>
				</xsl:choose>
			</div>
		</td>
		<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
	</tr>
	<tr><td colspan="5"><span class="micro"><xsl:call-template name="nobrspace"/></span></td></tr>
</xsl:template>

<xsl:template match="hintnormal">
	<xsl:apply-templates/>
</xsl:template>

<!-- =======================
	 Named templates section
	 ======================= -->
<xsl:template name="action-url">
	<xsl:value-of select="$x_baseurl"/>
	<xsl:choose>
		<xsl:when test="@link"><xsl:value-of select="@link"/></xsl:when>
		<xsl:otherwise><xsl:value-of select="$x_linkname"/></xsl:otherwise>
	</xsl:choose>
	<xsl:if test="@type"><xsl:text>&amp;type=</xsl:text><xsl:value-of select="@type"/></xsl:if>
	<xsl:if test="@name"><xsl:text>&amp;name=</xsl:text><xsl:value-of select="@name"/></xsl:if>
	<xsl:if test="@process"><xsl:text>&amp;process=</xsl:text><xsl:value-of select="@process"/></xsl:if>
	<xsl:if test="@sec"><xsl:text>&amp;sec=</xsl:text><xsl:value-of select="@sec"/></xsl:if>
	<xsl:if test="@sub"><xsl:text>&amp;sub=</xsl:text><xsl:value-of select="@sub"/></xsl:if>
	<xsl:if test="@prc"><xsl:text>&amp;prc=</xsl:text><xsl:value-of select="@prc"/></xsl:if>
	<xsl:if test="@pge"><xsl:text>&amp;pge=</xsl:text><xsl:value-of select="@pge"/></xsl:if>
</xsl:template>

<xsl:template name="form-name">
	<xsl:choose>
		<xsl:when test="ancestor-or-self::fields/@name"><xsl:value-of select="ancestor-or-self::fields/@name"/></xsl:when>
		<xsl:otherwise><xsl:text>x_form</xsl:text></xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="form-validation">
	<xsl:choose>
		<xsl:when test="@validation='src'">
			<script language="JavaScript" type="text/javascript">
				<xsl:attribute name="src"><xsl:text>scripts/</xsl:text><xsl:value-of select="@src"/></xsl:attribute>
				<xsl:call-template name="nobrspace"/>
			</script>	
		</xsl:when>
		<xsl:otherwise>
			<script language="JavaScript" type="text/javascript">
				<xsl:call-template name="form-valid"/>
			</script>	
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
			
<xsl:template name="form-valid">
	<xsl:text>function validateForm(frm){</xsl:text>
	<xsl:for-each select="fld[not(@input='readonly')]">
		<xsl:if test="mandatory='Y'">
			<xsl:if test="@type='special'">
				<xsl:variable name="thishint" select="hintvalid"/>
				<xsl:for-each select="subobjs/subwf_obj[@mandatory='Y']">
					<xsl:text>if (!x_val.</xsl:text>
					<xsl:choose>
						<xsl:when test="valid"><xsl:value-of select="valid"/></xsl:when>
						<xsl:otherwise>Text</xsl:otherwise>
					</xsl:choose>
					<xsl:text>(frm.fld_</xsl:text>
					<xsl:value-of select="@name"/>
					<xsl:text>, "</xsl:text>
					<xsl:value-of select="hintvalid"/>
					<xsl:text>"))return false;</xsl:text>
				</xsl:for-each>
			</xsl:if>
			<xsl:text>if (!x_val.</xsl:text>
			<xsl:choose>
				<xsl:when test="valid"><xsl:value-of select="valid"/></xsl:when>
				<xsl:otherwise>Text</xsl:otherwise>
			</xsl:choose>
			<xsl:text>(frm.fld_</xsl:text>
			<xsl:value-of select="@id"/>
			<xsl:text>, "</xsl:text>
			<xsl:value-of select="hintvalid"/>
			<xsl:text>"))return false;</xsl:text>
		</xsl:if>
	</xsl:for-each>
	<xsl:text>return true;}</xsl:text>
</xsl:template>

<xsl:template name="flds">
	<xsl:param name="isConfirm"/>
	<xsl:choose>
		<xsl:when test="@wf_obj='x_hidden'">
			<xsl:call-template name="input_notext">
				<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
			</xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
			<tr>
				<td class="frm_prompt">
					<xsl:choose>
						<xsl:when test="@wf_obj='x_agree'">
							<span class="frm_prmttxt"><xsl:text>I agree that</xsl:text></span>
						</xsl:when>
						<xsl:when test="@wf_obj='x_opt_check'">
							<span class="nano"><xsl:call-template name="nobrspace"/></span>
						</xsl:when>
						<xsl:otherwise>
							<span class="frm_prmttxt"><xsl:apply-templates select='prompt'/><xsl:text>:</xsl:text></span>
						</xsl:otherwise>
					</xsl:choose>
				</td>
				<td class="frm_hint"><xsl:call-template name="nobrspace"/></td>
			</tr>
			<tr>
				<td class="frm_fld">
					<xsl:if test="@hint='no'">
						<xsl:attribute name="colspan">2</xsl:attribute>
					</xsl:if>
					<xsl:choose>
						<!--
						<xsl:when test="@template">
							<xsl:call-template name="@template">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						-->
						<xsl:when test="@wf_obj='x_email' or
										@wf_obj='x_telno' or 
										@wf_obj='x_cellno' or 
										@wf_obj='x_input' or
										@wf_obj='x_input'
										">
							<xsl:call-template name="input_text">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test="@wf_obj='x_text'">
							<xsl:call-template name="textedit">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test="@wf_obj='x_info' or 
										@wf_obj='x_intro' or 
										@wf_obj='x_xml' or 
										@wf_obj='x_cms'">
							<xsl:call-template name="textarea">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test="@wf_obj='x_opt_radio' or 
										@wf_obj='x_yesno' or 
										@wf_obj='x_opt_profile' or 
										@wf_obj='x_opt_option'">
							<xsl:call-template name="select_radio_table">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test="@wf_obj='x_opt_check'">
							<xsl:call-template name="input_check">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test="@wf_obj='x_opt_checks'"><xsl:call-template name="input_check_multi"/></xsl:when>
						<xsl:when test="@wf_obj='x_drop' or 
										@wf_obj='x_archive' or
										@wf_obj='x_type' or
										@wf_obj='x_group'">
							<xsl:call-template name="select_drop">
								<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
							</xsl:call-template>
						</xsl:when>
						<xsl:when test="@wf_obj='x_password'">
							<xsl:call-template name="input_pass"/>
						</xsl:when>
						<xsl:when test="@wf_obj='x_date'">
							<xsl:call-template name="select_date"/>
						</xsl:when>
						<xsl:when test="@wf_obj='x_search'"><xsl:call-template name="input_search"/></xsl:when>
						<xsl:when test="@wf_obj='x_browse'"><xsl:call-template name="input_browse"/></xsl:when>
						<xsl:when test="@wf_obj='x_note'"><xsl:call-template name="input_note"/></xsl:when>
						<xsl:when test="@wf_obj='x_date_range'"><xsl:call-template name="input_date_range"/></xsl:when>
						<xsl:when test="@wf_obj='x_file'"><xsl:call-template name="input_file"/></xsl:when>
						<xsl:when test="@wf_obj='x_htmled'">
							<xsl:choose>
								<xsl:when test="$want_xed!='yes'"><xsl:call-template name="FCK_editor"/></xsl:when>
								<xsl:otherwise><xsl:call-template name="x_editor"/></xsl:otherwise>
							</xsl:choose>
						</xsl:when>
						<xsl:otherwise>
							<xsl:call-template name="default"/>
						</xsl:otherwise>
					</xsl:choose>
				</td>
					<xsl:if test="not(@hint='no')">
						<td class="frm_hint">
							<span class="frm_hinttxt">
								<xsl:choose>
									<xsl:when test="hintnormal!='' and $isConfirm!='yes' and not(@input='readonly')"><xsl:apply-templates select="hintnormal"/></xsl:when>
									<xsl:otherwise><xsl:call-template name="nobrspace"/></xsl:otherwise>
								</xsl:choose>
							</span>
						</td>
					</xsl:if>
			</tr>
		</xsl:otherwise>
	</xsl:choose>
	
</xsl:template>

<xsl:template name="special-flds">
	<xsl:param name="isConfirm"/>
	<tr>
		<td colspan="5">
			<table class="frm_table-special" cellpadding="0" cellspacing="0" border="0" width="100%">
				<xsl:choose>
					<xsl:when test="@wf_obj='nm_templ'">
						<xsl:call-template name="input_templ">
							<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@wf_obj='nm_period'">
						<xsl:call-template name="input_period">
							<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:when test="@wf_obj='nm_smssig'">
						<xsl:call-template name="input_smssig_special">
							<xsl:with-param name="confirm"><xsl:value-of select="$isConfirm"/></xsl:with-param>
						</xsl:call-template>
					</xsl:when>
					<xsl:otherwise>
						<xsl:call-template name="default"/>
					</xsl:otherwise>
				</xsl:choose>
			</table>
		</td>
	</tr>
	<tr><td colspan="5"><span class="milli"><xsl:call-template name="nobrspace"/></span></td></tr>
</xsl:template>


<!-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
		Named templates for the form fields
	 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
	<xsl:template name="input_class">
		<xsl:attribute name="class">
			<xsl:choose>
				<xsl:when test="mandatory='Y'">frm_inputmand</xsl:when>
				<xsl:otherwise>frm_input</xsl:otherwise>
			</xsl:choose>
		</xsl:attribute>
	</xsl:template>
	
	<xsl:template name="default">
		<xsl:call-template name="input_text"/>
	</xsl:template>
	
	<xsl:template name="input_note">
		<xsl:apply-templates select="value"/>
	</xsl:template>
	
	<xsl:template name="input_notext">
		<xsl:param name="confirm"/>
		<input type='Hidden'>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='size'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
			<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="input_text">
		<xsl:param name="confirm"/>
		<input type='Text'>
			<xsl:call-template name="input_class"/>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='size'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
			<xsl:if test="@input='readonly' or $confirm='yes'">
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>frm-readonly</xsl:text></xsl:attribute>
			</xsl:if>
		</input>
	</xsl:template>

	<xsl:template name="input_pass">
		<input type='Password'>
			<xsl:call-template name="input_class"/>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='size'><xsl:value-of select='length'/></xsl:attribute>
		</input>
	</xsl:template>
		
	<xsl:template name="input_check">
		<xsl:param name="confirm"/>
		<table cellpadding="0" cellspacing="0">
			<tr><td>
					<xsl:if test="not($confirm='yes')">
						<input type='checkbox' class="frm-fld-opt">
							<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
							<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
						</input>
					</xsl:if>
				</td>
				<td class="frm-fld-cellopt"><span class="frm-text"><xsl:apply-templates select='prompt'/></span></td>
			</tr>
		</table>
	</xsl:template>

	<xsl:template name="input_calc">
 		<xsl:param name="type"/> <!-- either 'text' or 'radio' -->
 		<xsl:param name="name"/>
 		<xsl:param name="id"/>
 		<xsl:param name="length"/>
 		<xsl:param name="value"/>
		<input> 
			<xsl:attribute name='type'><xsl:value-of select='$type'/></xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='$id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='$name'/></xsl:attribute>
			<xsl:choose>
				<xsl:when test="$type='radio'">
					<xsl:attribute name='class'><xsl:text>frm-fld-opt</xsl:text></xsl:attribute>
					<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
					<xsl:if test="value=$value">
						<xsl:attribute name='checked'></xsl:attribute>
					</xsl:if>
				</xsl:when>
				<xsl:otherwise>
					<xsl:attribute name='size'><xsl:value-of select='$length'/></xsl:attribute>
					<xsl:attribute name='value'><xsl:value-of select='$value'/></xsl:attribute>
				</xsl:otherwise>
			</xsl:choose>
		</input>
	</xsl:template>

	<xsl:template name="textarea">
		<xsl:param name="confirm"/>
		<textarea wrap='soft'>
			<xsl:call-template name="input_class"/>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='cols'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='rows'><xsl:value-of select='height'/></xsl:attribute>
			<xsl:if test="@input='readonly' or $confirm='yes'">
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>frm-readonly-txt</xsl:text></xsl:attribute>
			</xsl:if>
			<xsl:value-of select='value'/>
		</textarea>
	</xsl:template>

	<xsl:template name="textedit">
		<xsl:param name="confirm"/>
		<script language="javascript">
			<xsl:text>document.write(TextEditDecode("&lt;textarea wrap='soft' class='</xsl:text>
			<xsl:choose>
				<xsl:when test="mandatory='Y'">frm_inputmand</xsl:when>
				<xsl:otherwise>frm_input</xsl:otherwise>
			</xsl:choose>
			<xsl:text>' id='fld_</xsl:text><xsl:value-of select='@id'/>
			<xsl:text>' name='</xsl:text><xsl:value-of select='@name'/>
			<xsl:text>' cols='</xsl:text><xsl:value-of select='length'/>
			<xsl:text>' rows='</xsl:text><xsl:value-of select='height'/>
			<xsl:if test="@input='readonly' or $confirm='yes'">
				<xsl:text>' readonly='true</xsl:text>
			</xsl:if>
			<xsl:text>'&gt;</xsl:text><xsl:value-of select="value"/><xsl:text>&lt;/textarea&gt;"));</xsl:text>
		</script>
	</xsl:template>

	<xsl:template name="input_hidden">
 		<xsl:param name="name"/>
 		<xsl:param name="id"/>
	</xsl:template>

	<xsl:template name="input_multi">
		<xsl:param name="confirm"/>
	
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thislen" select="length"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="name"><xsl:value-of select='$thisname'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='$thisid'/></xsl:with-param>
		</xsl:call-template>

		<xsl:choose>
			<xsl:when test="@input='readonly' or $confirm='yes'">
				<div class="x_content-val" style="width:100px;">
					<xsl:attribute name='style'><xsl:text>width:</xsl:text><xsl:value-of select='length * 8'/><xsl:text>px;</xsl:text></xsl:attribute>
					<xsl:for-each select='subobjs/subwf_obj'>
						<xsl:value-of select='value'/><br/>
					</xsl:for-each>
				</div>
			</xsl:when>
			<xsl:otherwise>
				<table cellpadding="0" cellspacing="0">
					<xsl:for-each select='subobjs/subwf_obj'>
						<tr><td>
							<xsl:call-template name="input_calc">
								<xsl:with-param name="type">text</xsl:with-param>
								<xsl:with-param name="calc">calc_wf_multi</xsl:with-param>
								<xsl:with-param name="name"><xsl:value-of select='$thisname'/><xsl:value-of select='prompt'/></xsl:with-param>
								<xsl:with-param name="id"><xsl:value-of select='$thisid'/></xsl:with-param>
								<xsl:with-param name="length"><xsl:value-of select='$thislen'/></xsl:with-param>
								<xsl:with-param name="value"><xsl:value-of select='value'/></xsl:with-param>
							</xsl:call-template>
							</td>
							<!--<td><xsl:value-of select='prompt'/></td>-->
						</tr>
					</xsl:for-each>
				</table>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
						
	<xsl:template name="select_date_textyear">
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="name"><xsl:value-of select='@name'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
		</xsl:call-template>
		<select onchange='calc_wf_date(this)'>
		<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
		<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<option value='1'>01</option>
			<option value='2'>02</option>
			<option value='3'>03</option>
			<option value='4'>04</option>
			<option value='5'>05</option>
			<option value='6'>06</option>
			<option value='7'>07</option>
			<option value='8'>08</option>
			<option value='9'>09</option>
			<option value='10'>10</option>
			<option value='11'>11</option>
			<option value='12'>12</option>
			<option value='13'>13</option>
			<option value='14'>14</option>
			<option value='15'>15</option>
			<option value='16'>16</option>
			<option value='17'>17</option>
			<option value='18'>18</option>
			<option value='19'>19</option>
			<option value='20'>20</option>
			<option value='21'>21</option>
			<option value='22'>22</option>
			<option value='23'>23</option>
			<option value='24'>24</option>
			<option value='25'>25</option>
			<option value='26'>26</option>
			<option value='27'>27</option>
			<option value='28'>28</option>
			<option value='29'>29</option>
			<option value='30'>30</option>
			<option value='31'>31</option>
		</select>
		<select onchange='calc_wf_date(this)'>
		<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
		<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<option value='1'>January</option>
			<option value='2'>February</option>
			<option value='3'>March</option>
			<option value='4'>April</option>
			<option value='5'>May</option>
			<option value='6'>June</option>
			<option value='7'>July</option>
			<option value='8'>August</option>
			<option value='9'>September</option>
			<option value='10'>October</option>
			<option value='11'>November</option>
			<option value='12'>December</option>
		</select>
		<input type='Text' onchange='calc_wf_date(this)' size="4">
		<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
		<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
		</input>
	</xsl:template>
	
	<xsl:template name="select_radio">
		<xsl:param name="confirm"/>
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:variable name="thisval" select="value"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="name"><xsl:value-of select='@name'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
		</xsl:call-template>
		<xsl:choose>
			<xsl:when test="@input='readonly' or $confirm='yes'">
				<input type='Text'>
					<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
					<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
					<xsl:attribute name='size'><xsl:value-of select='length'/></xsl:attribute>
					<xsl:attribute name='value'><xsl:value-of select='subobjs/subwf_obj[value=$thisval]/prompt'/></xsl:attribute>
					<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
					<xsl:attribute name='class'><xsl:text>frm-readonly</xsl:text></xsl:attribute>
				</input>
			</xsl:when>
			<xsl:otherwise>
				<xsl:for-each select='subobjs/subwf_obj'>
					<xsl:call-template name="input_calc">
						<xsl:with-param name="type">radio</xsl:with-param>
						<xsl:with-param name="calc">calc_wf_radio</xsl:with-param>
						<xsl:with-param name="name"><xsl:value-of select='$thisname'/></xsl:with-param>
						<xsl:with-param name="id"><xsl:value-of select='$thisid'/></xsl:with-param>
						<xsl:with-param name="value"><xsl:value-of select='$thisval'/></xsl:with-param>
					</xsl:call-template>
					<span class="frm-text"><xsl:value-of select='prompt'/></span>
				</xsl:for-each>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>

<xsl:template name="select_radio_table">
	<xsl:param name="confirm"/>
	<xsl:variable name="thisname" select="@name"/>
	<xsl:variable name="thisid" select="@id"/>
	<xsl:variable name="thisval" select="value"/>
	<xsl:choose>
		<xsl:when test="@input='readonly' or $confirm='yes'">
			<input type='Text'>
				<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
				<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
				<xsl:attribute name='size'>40</xsl:attribute>
				<xsl:attribute name='value'><xsl:value-of select='subobjs/subwf_obj[value=$thisval]/prompt'/></xsl:attribute>
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>frm-readonly</xsl:text></xsl:attribute>
			</input>
		</xsl:when>
		<xsl:otherwise>
			<xsl:call-template name="input_hidden">
				<xsl:with-param name="name"><xsl:value-of select='@name'/></xsl:with-param>
				<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
			</xsl:call-template>
			<table cellpadding="0" cellspacing="2" class="x_content-subtable">
			<xsl:for-each select='subobjs/subwf_obj'>
				<tr><td width='20' align="left" valign="top">
					<xsl:call-template name="input_calc">
						<xsl:with-param name="type">radio</xsl:with-param>
						<xsl:with-param name="calc">calc_wf_radio</xsl:with-param>
						<xsl:with-param name="name"><xsl:value-of select='$thisname'/></xsl:with-param>
						<xsl:with-param name="id"><xsl:value-of select='$thisid'/></xsl:with-param>
						<xsl:with-param name="value"><xsl:value-of select='$thisval'/></xsl:with-param>
					</xsl:call-template>
					</td>
					<td class="frm-fld-cellopt"><span class="frm-text"><xsl:value-of select='prompt'/></span></td>
				</tr>
			</xsl:for-each>
			<xsl:for-each select='note/ps'>
				<tr><td><xsl:call-template name="nobrspace"/></td>
					<td><span class="frm-text"><xsl:value-of select='.'/></span></td>
				</tr>
			</xsl:for-each>
			</table>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>

<xsl:template name="select_drop">
	<xsl:param name="confirm"/>
	<xsl:variable name="thisid" select="@id"/>
	<xsl:variable name="thisval" select="value"/>
	<xsl:choose>
		<xsl:when test="$confirm='yes'">
			<input type='Text'>
				<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
				<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
				<xsl:attribute name='size'>40</xsl:attribute>
				<xsl:attribute name='value'>
					<xsl:if test="$thisval!='0'">
						<xsl:value-of select='subobjs/subwf_obj[value = $thisval]/prompt'/>
					</xsl:if>
				</xsl:attribute>
				<!--<xsl:attribute name='value'><xsl:value-of select='$thisval'/></xsl:attribute>-->
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>frm-readonly</xsl:text></xsl:attribute>
			</input>
		</xsl:when>
		<xsl:otherwise>
			<select>
			<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:for-each select='subobjs/subwf_obj'>
				<option>
				<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
				<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
				<xsl:if test="value=$thisval">
					<xsl:attribute name='selected'></xsl:attribute>
				</xsl:if>
				<xsl:value-of select='prompt'/>
				</option>
			</xsl:for-each>
			</select>
		</xsl:otherwise>
	</xsl:choose>
</xsl:template>
	
	<xsl:template name="select_expiry">
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="name"><xsl:value-of select='@name'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
		</xsl:call-template>
		<select onchange='calc_wf_expiry(this)'>
		<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
		<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<option value='0'>MM</option>
			<option value='01'>01</option>
			<option value='02'>02</option>
			<option value='03'>03</option>
			<option value='04'>04</option>
			<option value='05'>05</option>
			<option value='06'>06</option>
			<option value='07'>07</option>
			<option value='08'>08</option>
			<option value='09'>09</option>
			<option value='10'>10</option>
			<option value='11'>11</option>
			<option value='12'>12</option>
		</select>
		<select onchange='calc_wf_expiry(this)'>
		<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
		<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<option value='0'>YYYY</option>
			<option value='1'>2001</option>
			<option value='2'>2002</option>
			<option value='3'>2003</option>
			<option value='4'>2004</option>
			<option value='5'>2005</option>
			<option value='6'>2006</option>
			<option value='7'>2007</option>
			<option value='8'>2008</option>
			<option value='9'>2009</option>
			<option value='10'>2010</option>
		</select>
	</xsl:template>

	<xsl:template name="input_check_multi">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="name"><xsl:value-of select='@name'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
		</xsl:call-template>
		<table cellpadding="2" cellspacing="2">
		<xsl:for-each select='subobjs/subwf_obj'>
			<tr><td>
					<input type="Checkbox" class="frm-fld-opt">
						<xsl:attribute name='id'>fld_<xsl:value-of select='$thisid'/></xsl:attribute>
						<xsl:attribute name='name'><xsl:value-of select='$thisname'/></xsl:attribute>
					</input>
				</td>
				<td class="frm-fld-cellopt"><span class="frm-text"><xsl:value-of select='prompt'/></span></td>
			</tr>
		</xsl:for-each>
		</table>
	</xsl:template>
	
	<xsl:template name="input_sms">
		<xsl:param name="confirm"/>
		<textarea wrap='soft'>
			<xsl:attribute name='onkeyup'>javascript:SetSmsRemain(this, '<xsl:value-of select='hintnormal'/>');</xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='cols'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='rows'><xsl:value-of select='height'/></xsl:attribute>
			<xsl:if test="@input='readonly' or $confirm='yes'">
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>nm_form_readonly_textarea</xsl:text></xsl:attribute>
			</xsl:if>
			<xsl:value-of select='value'/>
		</textarea>
		<br/>
		<input class="frm-fld-count" type='Text' size="3">
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_count</xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/>_count</xsl:attribute>
			<xsl:attribute name='value'>160</xsl:attribute>
			<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
		</input>
		<span class="frm_hinttxt-count"> Characters remaining</span>
	</xsl:template>

	<xsl:template name="input_sms_sig">
		<xsl:param name="confirm"/>
		<input type='Text' size="10">
			<xsl:attribute name='onkeyup'>javascript:SetSmsRemainSig('fld_<xsl:value-of select='@id'/>', '<xsl:value-of select='hintnormal'/>');</xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_sig</xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/>_sig</xsl:attribute>
		</input><span class="frm_hinttxt">(who's this message from?)</span>
		<textarea wrap='soft'>
			<xsl:attribute name='onkeyup'>javascript:SetSmsRemainSig('fld_<xsl:value-of select='@id'/>', '<xsl:value-of select='hintnormal'/>');</xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='cols'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='rows'><xsl:value-of select='height'/></xsl:attribute>
			<xsl:if test="@input='readonly' or $confirm='yes'">
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>nm_form_readonly_textarea</xsl:text></xsl:attribute>
			</xsl:if>
			<xsl:value-of select='value'/>
		</textarea><br/>
		<input class="frm-fld-count" type='Text' size="3">
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_count</xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/>_count</xsl:attribute>
			<xsl:attribute name='value'>160</xsl:attribute>
			<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
		</input><span class="frm_hinttxt-count"> Characters remaining</span>
	</xsl:template>

	<xsl:template name="input_search">
		<xsl:call-template name="input_text"/><xsl:call-template name="nobrspace"/>
		<a>
			<xsl:attribute name="href">
				<xsl:value-of select='$x_baseurl'/>
				<xsl:value-of select='$x_linkname'/>
				<xsl:text>&amp;form=frmFindContact</xsl:text> <!-- becomes service -->
			</xsl:attribute>
			<xsl:call-template name="form-btn">
				<xsl:with-param name="btnname">btnSearch</xsl:with-param>
				<xsl:with-param name="btnaction">search</xsl:with-param>
			</xsl:call-template>
		</a>
		<xsl:if test="@wf_obj='nm_search_check'">
			<xsl:call-template name="nobrspace"/>
			<a>
				<xsl:attribute name="href">
					<xsl:value-of select='$x_baseurl'/>
					<xsl:value-of select='$x_linkname'/>
					<xsl:text>&amp;form=frmFindContact</xsl:text> <!-- becomes service -->
				</xsl:attribute>
				<xsl:call-template name="form-btn">
					<xsl:with-param name="btnname">btnCheck</xsl:with-param>
					<xsl:with-param name="btnaction">check</xsl:with-param>
				</xsl:call-template>
			</a>
		</xsl:if>
	</xsl:template>

	<xsl:template name="input_file">
		<xsl:param name="confirm"/>
		<input type="File" >
			<xsl:call-template name="input_class"/>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='size'><xsl:value-of select='length'/></xsl:attribute>
			<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>	<!-- has no effect! -->
			<xsl:if test="@input='readonly' or $confirm='yes'">
				<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				<xsl:attribute name='class'><xsl:text>frm-readonly</xsl:text></xsl:attribute>
			</xsl:if>
		</input>
		<xsl:if test="not(@input='readonly') and not($confirm='yes') and value!=''"><span class="frm_hinttxt"><br/>[currently: <xsl:value-of select="value"/>]</span></xsl:if>
	</xsl:template>

	<xsl:template name="input_browse">
		<xsl:call-template name="input_text"/><xsl:call-template name="nobrspace"/>
		<a>
			<xsl:attribute name="href">
				<xsl:value-of select='$x_baseurl'/>
				<xsl:value-of select='$x_linkname'/>
				<xsl:text>&amp;form=frmSearch&amp;process=Search</xsl:text>
			</xsl:attribute>
			<xsl:call-template name="form-btn">
				<xsl:with-param name="btnname">btnBrowse</xsl:with-param>
				<xsl:with-param name="btnaction">browse</xsl:with-param>
			</xsl:call-template>
		</a>
	</xsl:template>

	<xsl:template name="input_date_range">
		<xsl:variable name="thisname" select="@name"/>
		<xsl:variable name="thisid" select="@id"/>
		<xsl:call-template name="input_hidden">
			<xsl:with-param name="name"><xsl:value-of select='@name'/></xsl:with-param>
			<xsl:with-param name="id"><xsl:value-of select='@id'/></xsl:with-param>
		</xsl:call-template>
		<table cellpadding="2" cellspacing="2" border="0">
			<xsl:for-each select='subobjs/subwf_obj'>
				<tr><xsl:call-template name="period_date">
						<xsl:with-param name="prompt"><xsl:value-of select='prompt'/></xsl:with-param>
					</xsl:call-template>
				</tr>
			</xsl:for-each>
		</table>
	</xsl:template>

	<xsl:template name="x_editor">
		<xsl:variable name="thisid">fld_<xsl:value-of select='@id'/></xsl:variable>
		<xsl:variable name="thisspace"><xsl:value-of select="$x_fields/fld[@name='BlogSpaces']/value"/></xsl:variable>
		<!-- Constants -->
		<script language="javascript" src="../xed/scripts/dhtmled.js"></script>
		<script language="javascript" src="../xed/scripts/x_itext.js"></script>
		<!-- Includes -->
		<script language="javascript" src="../xed/scripts/x_editor.js"></script>
		<script language="javascript" src="../xed/scripts/x_config.js"></script>
		<script language="javascript" src="../xed/scripts/x_toolbar.js"></script>
		<script language="javascript" src="../xed/scripts/x_xhtml.js"></script>
		<script language="javascript" src="../xed/scripts/x_contextmenu.js"></script>
		<script language="javascript" src="../xed/scripts/x_lang.js"></script>
		<!-- Instances and arrays -->
		<script language="javascript" src="../xed/scripts/x_instance.js"></script>
		<!-- DEC Events -->
		<script language="javascript" event="DocumentComplete"				for="objContent">
			<xsl:text>x_config.SetStyle('</xsl:text><xsl:value-of select="$x_siteurl"/><xsl:text>styles/</xsl:text><xsl:value-of select="$thisspace"/><xsl:text>/x_editor.css</xsl:text>');	
			<xsl:text>x_config.SetToolbar('</xsl:text><xsl:value-of select="$thisspace"/><xsl:text>');</xsl:text>
			<xsl:text>x_editor.Init('</xsl:text><xsl:value-of select="$thisid"/><xsl:text>');</xsl:text>
		</script>
		<script language="javascript" event="onerror(msg, url, line)"		for="window">x_editor.Debug(msg, 'line', line);</script>
		<script language="javascript" event="DisplayChanged"				for="objContent">x_editor.FireEvent('onEditing');</script>
		<script language="javascript" event="ShowContextMenu"				for="objContent">x_contextMenu.Show();</script>
		<script language="javascript" event="ContextMenuAction(itemIndex)"	for="objContent">x_contextMenu.Action(itemIndex);</script>
		<table height="100%" cellspacing="0" cellpadding="0" width="100%">
			<tr id="trEditor">
				<td>
					<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
						<tr>
							<td><div id="divToolbar" class="xed_tool"></div></td>
						</tr>
						<tr height="100%">
							<td>
								<object id="objContent" class="xed_text" classid="clsid:2D360201-FFF5-11D1-8D03-00A0C959BC0A" viewastext="true">
									<param name="ActivateApplets" value="0"/>
									<param name="ActivateActiveXControls" value="0"/>
									<param name="ActivateDTCs" value="1"/>
									<param name="ShowDetails" value="0"/>
									<param name="ShowBorders" value="1"/>
									<param name="Appearance" value="1"/>
									<param name="Scrollbars" value="1"/>
									<param name="ScrollbarAppearance" value="1"/>
									<param name="SourceCodePreservation" value="1"/>
									<param name="AbsoluteDropMode" value="0"/>
									<param name="SnapToGrid" value="0"/>
									<param name="SnapToGridX" value="50"/>
									<param name="SnapToGridY" value="50"/>
									<param name="UseDivOnCarriageReturn" value="1"/>
								</object>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr id="trSource" style="DISPLAY: none">
				<td>
					<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
						<tr>
							<td><div id="divToolbarSource"></div></td>
						</tr>
						<tr height="100%">
							<td><textarea class="xed_text" id="txtSource"></textarea></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<div id="divTemp" style="VISIBILITY:hidden; OVERFLOW:hidden; POSITION:absolute; WIDTH: 1px; HEIGHT: 1px"></div>
		<input type="hidden">
			<xsl:attribute name="name"><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name="id"><xsl:value-of select="$thisid"/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="x_editor_frame">
		<xsl:param name="confirm"/>
		<iframe frameborder="no" scrolling="no">
			<xsl:attribute name="src"><xsl:value-of select="$x_siteurl"/><xsl:text>xed/editorX.html</xsl:text></xsl:attribute>
			<xsl:attribute name="width"><xsl:value-of select='width'/></xsl:attribute>
			<xsl:attribute name="height"><xsl:value-of select='height'/></xsl:attribute>
		</iframe>
		<input type="hidden">
			<xsl:attribute name="name"><xsl:value-of select='@name'/></xsl:attribute>
			<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
			<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
		</input>
	</xsl:template>

	<xsl:template name="FCK_editor">
		<xsl:param name="confirm"/>
		<xsl:variable name="thisspace"><xsl:value-of select="$x_fields/fld[@name='BlogSpaces']/value"/></xsl:variable>
		<script language="javascript">
			x_frm.FCKEditor("<xsl:value-of select="$x_serverurl"/>", "<xsl:value-of select='@name'/>", <xsl:value-of select='width'/>, <xsl:value-of select='height'/>, "<xsl:value-of select='$thisspace'/>", "<xsl:value-of select="value" disable-output-escaping="yes"/>")
		</script>
	</xsl:template>

	
<!--	==============================
		templates for 'special' fields
		==============================	-->

	<xsl:template name="input_smssig_special">
		<xsl:param name="confirm"/>
		<xsl:variable name="sig" select="subobjs/subwf_obj[@name='sig']"/>
		<xsl:variable name="cnt" select="subobjs/subwf_obj[@name='count']"/>
		<tr>
			<td class="frm-spe-cellask">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
				<span class="frm_prmttxt"><xsl:value-of select="$sig/prompt"/></span>
			</td>
			<td class="frm-fld-cellspc"><xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
			<td class="frm-fld-cellans">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
				<input type='Text' size="15">
					<xsl:attribute name='onkeyup'>javascript:SetSmsRemainSig('fld_<xsl:value-of select='@id'/>', '<xsl:value-of select='hintnormal'/>');</xsl:attribute>
					<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_<xsl:value-of select="$sig/@name"/></xsl:attribute>
					<xsl:attribute name='name'><xsl:value-of select='@name'/>_<xsl:value-of select="$sig/@name"/></xsl:attribute>
				</input>
			</td>
			<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
		</tr>
		<tr>
			<td class="frm-spe-cellask">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
				<span class="frm_prmttxt"><xsl:value-of select="prompt"/></span>
			</td>
			<td class="frm-fld-cellspc"><xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
			<td class="frm-fld-cellans">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
				<textarea wrap='soft'>
					<xsl:attribute name='onkeyup'>javascript:SetSmsRemainSig('fld_<xsl:value-of select='@id'/>', '<xsl:value-of select='hintnormal'/>');</xsl:attribute>
					<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/></xsl:attribute>
					<xsl:attribute name='name'><xsl:value-of select='@name'/></xsl:attribute>
					<xsl:attribute name='cols'><xsl:value-of select='length'/></xsl:attribute>
					<xsl:attribute name='rows'><xsl:value-of select='height'/></xsl:attribute>
					<xsl:if test="@input='readonly' or $confirm='yes'">
						<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
						<xsl:attribute name='class'><xsl:text>nm_form_readonly_textarea</xsl:text></xsl:attribute>
					</xsl:if>
					<xsl:value-of select='value'/>
				</textarea>
				<br/>
				<input class="frm-fld-count" type='Text' size="3">
					<xsl:attribute name='id'>fld_<xsl:value-of select='@id'/>_count</xsl:attribute>
					<xsl:attribute name='name'><xsl:value-of select='@name'/>_count</xsl:attribute>
					<xsl:attribute name='value'>160</xsl:attribute>
					<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				</input>
				<span class="frm_hinttxt-count"> Characters remaining</span>
			</td>
			<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
		</tr>
	</xsl:template>

	<xsl:template name="input_templ">
		<xsl:param name="confirm"/>
		<xsl:variable name="fldname" select="@name"/>
		<xsl:variable name="fldid" select="@id"/>
		<xsl:variable name="fldhint" select="hintnormal"/>
		<!-- template name -->
		<tr>
			<td class="frm-spe-cellask">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
				<span class="frm_prmttxt">Template</span>
			</td>
			<td class="frm-fld-cellspc"><xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
			<td class="frm-fld-cellans">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
				<div class="frm-fld-spec"><xsl:apply-templates select='prompt'/></div>
			</td>
			<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
		</tr>
		<!-- template text -->
		<tr>
			<td class="frm-spe-cellask">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
				<span class="frm_prmttxt">Message template text</span>
			</td>
			<td class="frm-fld-cellspc"><xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
			<td class="frm-fld-cellans">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
				<div>
					<xsl:attribute name="id">fld_<xsl:value-of select='$fldid'/></xsl:attribute>
					<xsl:attribute name="class">frm-fld-<xsl:value-of select="@name"/></xsl:attribute>
					<xsl:apply-templates select='value'/>
				</div>
			</td>
			<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
		</tr>
		<!-- template fields -->
		<xsl:for-each select="subobjs/subwf_obj">
			<tr>
				<td class="frm-fld-cellask">
					<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
					<span class="frm_prmttxt"><xsl:value-of select='prompt'/></span>
				</td>
				<td class="frm-fld-cellspc"><xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
				<td class="frm-fld-cellans">
					<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
					<input type='Text' size="20">
						<xsl:attribute name='onkeyup'>javascript:SetTmplRemain('fld_<xsl:value-of select='$fldid'/>', '<xsl:value-of select="prompt"/>', '<xsl:value-of select='$fldhint'/>');</xsl:attribute>
						<xsl:attribute name='id'>fld_<xsl:value-of select="prompt"/></xsl:attribute>
						<xsl:attribute name='name'><xsl:value-of select="@name"/></xsl:attribute>
						<xsl:attribute name='value'><xsl:value-of select='value'/></xsl:attribute>
					</input>
				</td>
				<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
			</tr>
			<tr><td colspan="4" width="*"><span class="pico"><xsl:call-template name="nobrspace"/></span></td></tr>
		</xsl:for-each>
		<!-- template count -->
		<tr>
			<td class="frm-spe-cellask">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
				<span class="frm_hinttxt-count"> Characters remaining</span>
			</td>
			<td class="frm-fld-cellspc"><xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
			<td class="frm-fld-cellans">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
				<input class="frm-fld-count" type='Text' size="3">
					<xsl:attribute name='id'>fld_<xsl:value-of select='$fldid'/>_count</xsl:attribute>
					<xsl:attribute name='name'><xsl:value-of select='$fldname'/>_count</xsl:attribute>
					<xsl:attribute name='value'>160</xsl:attribute>
					<xsl:attribute name='readonly'><xsl:text>true</xsl:text></xsl:attribute>
				</input>
			</td>
			<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
		</tr>
	</xsl:template>

	<xsl:template match="fld[@type='special']/value">
		<xsl:apply-templates/>
	</xsl:template>

	<xsl:template match="fld/value/param">
		<span class="frm-fld-param">
			<xsl:attribute name='id'>span_<xsl:value-of select='@name'/></xsl:attribute>
			<xsl:apply-templates/></span>
	</xsl:template>

	<xsl:template name="input_period">
		<xsl:param name="confirm"/>
		<xsl:variable name="fldname" select="@name"/>
		<xsl:variable name="fldid" select="@id"/>
		<tr>
			<td class="frm-fld-cellask">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellask']"/></xsl:attribute>
				<span class="frm_prmttxt"><xsl:value-of select="prompt"/></span>
			</td>
			<td class="frm-fld-cellspc">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellspc'] + $x_site//cell[@name='frm-cellsml']"/></xsl:attribute><xsl:call-template name="nobrspace"/></td>
			<td class="frm-fld-cellans">
				<xsl:attribute name="width"><xsl:value-of select="$x_site//cell[@name='frm-cellans']"/></xsl:attribute>
				<table>
					<xsl:for-each select="subobjs/subwf_obj">
						<tr>
							<td>
								<input type="radio">
									<xsl:attribute name="id"><xsl:value-of select="$fldid"/></xsl:attribute>
								</input>
								<xsl:choose>
									<xsl:when test="@type='date'">
										<table><xsl:attribute name="class">frm-fld-<xsl:value-of select="@name"/></xsl:attribute>
											<tr><xsl:call-template name="period_date"><xsl:with-param name="prompt">From</xsl:with-param></xsl:call-template></tr>
											<tr><xsl:call-template name="period_date"><xsl:with-param name="prompt">To</xsl:with-param></xsl:call-template></tr>
										</table>
									</xsl:when>
									<xsl:otherwise>	<!-- must be type='time'-->
										<div><xsl:attribute name="class">frm-fld-<xsl:value-of select="@name"/></xsl:attribute>
											<xsl:call-template name="period_time"/></div>
									</xsl:otherwise>
								</xsl:choose>
							</td>
							<td width="*"><xsl:call-template name="nobrspace"/></td>
						</tr>
					</xsl:for-each>
				</table>
			</td>
			<td class="frm-fld-cellspc" width="*"><xsl:call-template name="nobrspace"/></td>
		</tr>
	</xsl:template>

	<xsl:template name="period_date">
		<xsl:param name="prompt"/>
		<td class="frm-fld-cellopt"><span class="frm_prmttxt"><xsl:value-of select="$prompt"/></span></td>
		<td class="frm-fld-cellopt">
			<input type="Text" size="15">
				<xsl:attribute name='name'><xsl:value-of select='@name'/><xsl:text>_date</xsl:text></xsl:attribute>
			</input>
		</td>
		<td class="frm-fld-cellopt">
			<select>
				<xsl:attribute name='name'><xsl:value-of select='@name'/><xsl:text>_hours</xsl:text></xsl:attribute>
				<option value='00'>HH</option>
				<option value='00'>00</option>
				<option value='01'>01</option>
				<option value='02'>02</option>
				<option value='03'>03</option>
				<option value='04'>04</option>
				<option value='05'>05</option>
				<option value='06'>06</option>
				<option value='07'>07</option>
				<option value='08'>08</option>
				<option value='09'>09</option>
				<option value='10'>10</option>
				<option value='11'>11</option>
				<option value='12'>12</option>
				<option value='13'>13</option>
				<option value='14'>14</option>
				<option value='15'>15</option>
				<option value='16'>16</option>
				<option value='17'>17</option>
				<option value='18'>18</option>
				<option value='19'>19</option>
				<option value='20'>20</option>
				<option value='21'>21</option>
				<option value='22'>22</option>
				<option value='23'>23</option>
				<option value='24'>24</option>
			</select>
		</td>
		<td class="frm-fld-cellopt">
			<select>
				<xsl:attribute name='name'><xsl:value-of select='@name'/><xsl:text>_mins</xsl:text></xsl:attribute>
				<option value='00'>MM</option>
				<option value='00'>00</option>
				<option value='05'>05</option>
				<option value='10'>10</option>
				<option value='15'>15</option>
				<option value='20'>20</option>
				<option value='25'>25</option>
				<option value='30'>30</option>
				<option value='35'>35</option>
				<option value='40'>40</option>
				<option value='45'>45</option>
				<option value='50'>50</option>
				<option value='55'>55</option>
			</select>
		</td>
	</xsl:template>

	<xsl:template name="period_time">
		<span class="frm_prmttxt"><xsl:value-of select="prompt"/></span>
		<select>
			<xsl:attribute name='name'><xsl:value-of select='@name'/><xsl:text>_hours</xsl:text></xsl:attribute>
			<option value='00'>00</option>
			<option value='01'>01</option>
			<option value='02'>02</option>
			<option value='03'>03</option>
			<option value='04'>04</option>
			<option value='05'>05</option>
			<option value='06'>06</option>
			<option value='07'>07</option>
			<option value='08'>08</option>
			<option value='09'>09</option>
			<option value='10'>10</option>
			<option value='11'>11</option>
			<option value='12'>12</option>
			<option value='13'>13</option>
			<option value='14'>14</option>
			<option value='15'>15</option>
			<option value='16'>16</option>
			<option value='17'>17</option>
			<option value='18'>18</option>
			<option value='19'>19</option>
			<option value='20'>20</option>
			<option value='21'>21</option>
			<option value='22'>22</option>
			<option value='23'>23</option>
			<option value='24'>24</option>
		</select>
		<select>
			<xsl:attribute name='name'><xsl:value-of select='@name'/><xsl:text>_mins</xsl:text></xsl:attribute>
			<option value='00'>00</option>
			<option value='05'>05</option>
			<option value='10'>10</option>
			<option value='15'>15</option>
			<option value='20'>20</option>
			<option value='25'>25</option>
			<option value='30'>30</option>
			<option value='35'>35</option>
			<option value='40'>40</option>
			<option value='45'>45</option>
			<option value='50'>50</option>
			<option value='55'>55</option>
		</select>
	</xsl:template>

	<xsl:template name="select_date">
		<xsl:param name="thisname" select="@name"/>
		<xsl:variable name="this_yy" select="substring(value,1,4)" />
		<xsl:variable name="this_mm" select="substring(value,6,2)" />
		<xsl:variable name="this_dd" select="substring(value,9,2)" />
		<xsl:comment>select_date::<xsl:value-of select="count(subobjs)"/>:<xsl:value-of select="$thisname"/></xsl:comment>
		<!-- Day -->
		<xsl:call-template name="pick_date">
			<xsl:with-param name="which">day</xsl:with-param>
			<xsl:with-param name="thisval" select="$this_dd" />
		</xsl:call-template>
		<!-- Month -->
		<xsl:call-template name="pick_date">
			<xsl:with-param name="which">month</xsl:with-param>
			<xsl:with-param name="thisval" select="$this_mm" />
		</xsl:call-template>
		<!-- Year -->
		<xsl:call-template name="pick_date">
			<xsl:with-param name="which">year</xsl:with-param>
			<xsl:with-param name="thisval" select="$this_yy" />
		</xsl:call-template>
	</xsl:template>
	
	<xsl:template name="pick_date">
		<xsl:param name="which" />
		<xsl:param name="thisval" />
		<xsl:comment>pick_date::<xsl:value-of select="$which"/>:<xsl:value-of select="$thisval"/></xsl:comment>
		<select>
			<xsl:attribute name="name"><xsl:value-of select="@name"/>_<xsl:value-of select="$which"/></xsl:attribute>
			<xsl:attribute name="id">
				<xsl:text>fld_</xsl:text><xsl:value-of select="@id"/>
				<xsl:text>_</xsl:text><xsl:value-of select="$which"/>
			</xsl:attribute>
			<!-- add the year options from the subobjs element -->
			<xsl:for-each select="subobjs[@name=$which]/subwf_obj">
				<option>
					<xsl:attribute name="value"><xsl:value-of select="value"/></xsl:attribute>
					<xsl:if test="value=$thisval">
						<xsl:attribute name="selected">true</xsl:attribute>
					</xsl:if>
					<xsl:value-of select="prompt"/>
				</option>
			</xsl:for-each>
		</select>
	</xsl:template>
		
</xsl:stylesheet>
